package com.bit.IO;

import java.io.*;

public class IOTest4 {
    public static void main(String[] args) {
        fileTest("d:/test/1234.jpg","d:/test/2.jpg");
        bufferTest("d:/test/1234.jpg","d:/test/2.jpg");
    }
    private static void fileTest(String srcPath,String desPath){
        long start = System.currentTimeMillis();
        try(FileInputStream fileInputStream = new FileInputStream(srcPath);
            FileOutputStream fileOutputStream = new FileOutputStream(desPath)){
            int len = -1;
            while((len = fileInputStream.read()) != -1){

            }
        }catch (IOException e){
            e.printStackTrace();
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }
    private static void bufferTest(String srcPath,String desPath){
        long start = System.currentTimeMillis();
        try(BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(srcPath));){
            int len = -1;
            while((len = bufferedInputStream.read()) != -1){

            }
        }catch (IOException e){
            e.printStackTrace();
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }
}
